package com.caogen.cg_wl_kt.ui.welcome

import android.content.Intent
import android.os.Bundle
import android.os.CountDownTimer
import android.webkit.WebViewClient
import com.bumptech.glide.Glide
import com.caogen.cg_wl_kt.MainActivity
import com.caogen.cg_wl_kt.base.BaseActivity
import com.caogen.cg_wl_kt.base.BaseViewModel
import com.caogen.cg_wl_kt.databinding.ActivityWelcomeBinding
import com.caogen.cg_wl_kt.ui.login.UpdatePwdActivity

class WelcomeActivity:BaseActivity<ActivityWelcomeBinding,BaseViewModel>(
    ActivityWelcomeBinding::inflate,
    BaseViewModel::class.java
){
    private val countdownTime = 0
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding.webView.settings.javaScriptEnabled = true
        binding.webView.webViewClient = WebViewClient()
//        binding.webView.loadUrl("https://www.baidu.com")
//        Glide.with(this).load("").into(binding.ivLogo)

        startCountdown()
    }

    private fun startCountdown() {
        object : CountDownTimer(countdownTime * 1000L, 1000L) {

            override fun onTick(millisUntilFinished: Long) {
                val secondsLeft = millisUntilFinished / 1000 % 60
//                timerTextView.text = "${secondsLeft}秒"
            }

            override fun onFinish() {
                toActivity()
            }
        }.start()
    }

    fun toActivity(){
        var intent = Intent(this, MainActivity::class.java);
        startActivity(intent)
    }
}